#! /bin/bash

echo $1
echo $2

if [ -n "$2" ] ;
then
  do_date=$2
else
  do_date=`date -d '-1 day' +%F`
fi

pwd=/opt/module/rebate-report/business

execute_shell(){
  sh $pwd/$1.sh all $do_date
}

case $1 in
"all")
  execute_shell "mysql_to_hdfs"
  execute_shell "ods_to_dwd"
  execute_shell "ods_to_dwd_dim"
  execute_shell "dwd_to_dws_company"
  execute_shell "dwd_to_dws_station"
  execute_shell "output_dim"
  execute_shell "output_dim_bi"
  execute_shell "dws_to_app_company"
  execute_shell "dws_to_app_station"
  execute_shell "dws_to_tmp_station"
  execute_shell "output_company"
  execute_shell "output_station"
  execute_shell "output_company_bi"
  execute_shell "output_station_bi"
  ;;
"mysql_to_hdfs")
  execute_shell "mysql_to_hdfs"
  ;;
"ods_to_dwd")
  execute_shell "ods_to_dwd"
  ;;
"ods_to_dwd_dim")
  execute_shell "ods_to_dwd_dim"
  ;;
"dwd_to_dws_company")
  execute_shell "dwd_to_dws_company"
  ;;
"dwd_to_dws_station")
  execute_shell "dwd_to_dws_station"
  ;;
"output_dim")
  execute_shell "output_dim"
  ;;
"output_dim_bi")
  execute_shell "output_dim_bi"
  ;;
"dws_to_app_company")
  execute_shell "dws_to_app_company"
  ;;
"dws_to_app_station")
  execute_shell "dws_to_app_station"
  ;;
"dws_to_tmp_station")
  execute_shell "dws_to_tmp_station"
  ;;
"output_company")
  execute_shell "output_company"
  ;;
"output_station")
  execute_shell "output_station"
  ;;
"output_company_bi")
  execute_shell "output_company_bi"
  ;;
"output_station_bi")
  execute_shell "output_station_bi"
  ;;
esac